home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / WINDOWS / DIVERSEN / WINE02BX / EMACS.8 < prev    next >
Text File  |  1993-03-28  |  48KB  |  1,156 lines

  1. Info file ../info/emacs, produced by Makeinfo, -*- Text -*- from input
  2. file lemacs.tex.
  3.  
  4.    This file documents the GNU Emacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992 Lucid, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of
  10. this manual provided the copyright notice and this permission notice
  11. are preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  16. General Public License" are included exactly as in the original, and
  17. provided that the entire resulting derived work is distributed under
  18. the terms of a permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "The GNU Manifesto",
  23. "Distribution" and "GNU General Public License" may be included in a
  24. translation approved by the author instead of in the original English.
  25.  
  26. 
  27. File: emacs,  Node: Words,  Next: Sentences,  Prev: Text Mode,  Up: Text
  28.  
  29. Words
  30. =====
  31.  
  32.    Emacs has commands for moving over or operating on words.  By
  33. convention, the keys for them are all `Meta-' characters.
  34.  
  35. `M-f'
  36.      Move forward over a word (`forward-word').
  37.  
  38. `M-b'
  39.      Move backward over a word (`backward-word').
  40.  
  41. `M-d'
  42.      Kill up to the end of a word (`kill-word').
  43.  
  44. `M-DEL'
  45.      Kill back to the beginning of a word (`backward-kill-word').
  46.  
  47. `M-@'
  48.      Mark the end of the next word (`mark-word').
  49.  
  50. `M-t'
  51.      Transpose two words;  drag a word forward or backward across
  52.      other words (`transpose-words').
  53.  
  54.    Notice how these keys form a series that parallels the
  55. character-based `C-f', `C-b', `C-d', `C-t' and DEL.  `M-@' is related
  56. to `C-@', which is an alias for `C-SPC'.
  57.  
  58.    The commands `Meta-f' (`forward-word') and `Meta-b'
  59. (`backward-word') move forward and backward over words.  They are
  60. analogous to `Control-f' and `Control-b', which move over single
  61. characters.  Like their `Control-' analogues, `Meta-f' and `Meta-b'
  62. move several words if given an argument.  `Meta-f' with a negative
  63. argument moves backward, and `Meta-b' with a negative argument moves
  64. forward.  Forward motion stop after the last letter of the word, while
  65. backward motion stops before the first letter.
  66.  
  67.    `Meta-d' (`kill-word') kills the word after point.  To be precise,
  68. it kills everything from point to the place `Meta-f' would move to. 
  69. Thus, if point is in the middle of a word, `Meta-d' kills just the
  70. part after point.  If some punctuation comes between point and the
  71. next word, it is killed along with the word.  (To kill only the next
  72. word but not the punctuation before it, simply type `Meta-f' to get
  73. the end, and kill the word backwards with `Meta-DEL'.) `Meta-d' takes
  74. arguments just like `Meta-f'.
  75.  
  76.    `Meta-DEL' (`backward-kill-word') kills the word before point.  It
  77. kills everything from point back to where `Meta-b' would move to.  If
  78. point is after the space in `FOO, BAR', then `FOO, ' is killed.   To
  79. kill just `FOO', type `Meta-b Meta-d' instead of `Meta-DEL'.)
  80.  
  81.    `Meta-t' (`transpose-words') exchanges the word before or
  82. containing point with the following word.  The delimiter characters
  83. between the words do not move.  For example, transposing `FOO, BAR'
  84. results in `BAR, FOO' rather than `BAR FOO,'.  *Note Transpose::, for
  85. more on transposition and on arguments to transposition commands.
  86.  
  87.    To operate on the next N words with an operation which applies
  88. between point and mark, you can either set the mark at point and then
  89. move over the words, or you can use the command `Meta-@' (`mark-word')
  90. which does not move point, but sets the mark where `Meta-f' would move
  91. to.  It can be given arguments just like `Meta-f'.
  92.  
  93.    The word commands' understanding of syntax is completely controlled
  94. by the syntax table.  Any character can, for example, be declared to
  95. be a word delimiter.  *Note Syntax::.
  96.  
  97. 
  98. File: emacs,  Node: Sentences,  Next: Paragraphs,  Prev: Words,  Up: Text
  99.  
  100. Sentences
  101. =========
  102.  
  103.    The Emacs commands for manipulating sentences and paragraphs are
  104. mostly on `Meta-' keys, and therefore like the word-handling commands.
  105.  
  106. `M-a'
  107.      Move back to the beginning of the sentence (`backward-sentence').
  108.  
  109. `M-e'
  110.      Move forward to the end of the sentence (`forward-sentence').
  111.  
  112. `M-k'
  113.      Kill forward to the end of the sentence (`kill-sentence').
  114.  
  115. `C-x DEL'
  116.      Kill back to the beginning of the sentence 
  117.      (`backward-kill-sentence').
  118.  
  119.    The commands `Meta-a' and `Meta-e' (`backward-sentence' and
  120. `forward-sentence') move to the beginning and end of the current
  121. sentence, respectively.  They resemble `Control-a' and `Control-e',
  122. which move to the beginning and end of a line.  Unlike their
  123. counterparts, `Meta-a' and `Meta-e' move over successive sentences if
  124. repeated or given numeric arguments.  Emacs assumes the typist's
  125. convention is followed, and thus considers a sentence to end wherever
  126. there is a `.', `?' or `!' followed by the end of a line or two
  127. spaces, with any number of `)', `]', `'', or `"' characters allowed in
  128. between.  A sentence also begins or ends wherever a paragraph begins
  129. or ends.
  130.  
  131.    Neither `M-a' nor `M-e' moves past the newline or spaces beyond the
  132. sentence edge at which it is stopping.
  133.  
  134.    `M-a' and `M-e' have a corresponding kill command, just like `C-a'
  135. and `C-e' have `C-k'.  The command is  `M-k' (`kill-sentence') which
  136. kills from point to the end of the sentence.  With minus one as an
  137. argument it kills back to the beginning of the sentence.  Larger
  138. arguments serve as repeat counts.
  139.  
  140.    There is a special command, `C-x DEL' (`backward-kill-sentence')
  141. for killing back to the beginning of a sentence, which is useful when
  142. you change your mind in the middle of composing text.
  143.  
  144.    The variable `sentence-end' controls recognition of the end of a
  145. sentence.  It is a regexp that matches the last few characters of a
  146. sentence, together with the whitespace following the sentence.  Its
  147. normal value is
  148.  
  149.      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
  150.  
  151. This example is explained in the section on regexps.  *Note Regexps::.
  152.  
  153. 
  154. File: emacs,  Node: Paragraphs,  Next: Pages,  Prev: Sentences,  Up: Text
  155.  
  156. Paragraphs
  157. ==========
  158.  
  159.    The Emacs commands for manipulating paragraphs are also `Meta-'
  160. keys.
  161.  
  162. `M-['
  163.      Move back to previous paragraph beginning 
  164.      (`backward-paragraph').
  165.  
  166. `M-]'
  167.      Move forward to next paragraph end (`forward-paragraph').
  168.  
  169. `M-h'
  170.      Put point and mark around this or next paragraph
  171.      (`mark-paragraph').
  172.  
  173.    `Meta-[' moves to the beginning of the current or previous
  174. paragraph, while `Meta-]' moves to the end of the current or next
  175. paragraph.  Blank lines and text formatter command lines separate
  176. paragraphs and are not part of any paragraph.  An indented line starts
  177. a new paragraph.
  178.  
  179.    In major modes for programs (as opposed to Text mode), paragraphs
  180. begin and end only at blank lines.  As a result, the paragraph
  181. commands continue to be useful even though there are no paragraphs per
  182. se.
  183.  
  184.    When there is a fill prefix, paragraphs are delimited by all lines
  185. which don't start with the fill prefix.  *Note Filling::.
  186.  
  187.    To operate on a paragraph, you can use the command `Meta-h'
  188. (`mark-paragraph') to set the region around it.  This command puts
  189. point at the beginning and mark at the end of the paragraph point was
  190. in.  If point is between paragraphs (in a run of blank lines, or at a
  191. boundary), the paragraph following point is surrounded by point and
  192. mark.  If there are blank lines preceding the first line of the
  193. paragraph, one of the blank lines is included in the region.  Thus,
  194. for example, `M-h C-w' kills the paragraph around or after point.
  195.  
  196.    The precise definition of a paragraph boundary is controlled by the
  197. variables `paragraph-separate' and `paragraph-start'.  The value of
  198. `paragraph-start' is a regexp that matches any line that either starts
  199. or separates paragraphs.  The value of `paragraph-separate' is another
  200. regexp that  matches only lines that separate paragraphs without being
  201. part of any paragraph.  Lines that start a new paragraph and are
  202. contained in it must match both regexps.  For example, normally
  203. `paragraph-start' is `"^[ \t\n\f]"' and `paragraph-separate' is `"^[
  204. \t\f]*$"'.
  205.  
  206.    Normally it is desirable for page boundaries to separate paragraphs. 
  207. The default values of these variables recognize the usual separator for
  208. pages.
  209.  
  210. 
  211. File: emacs,  Node: Pages,  Next: Filling,  Prev: Paragraphs,  Up: Text
  212.  
  213. Pages
  214. =====
  215.  
  216.    Files are often thought of as divided into "pages" by the
  217. "formfeed" character (ASCII Control-L, octal code 014).  For example,
  218. if a file is printed on a line printer, each "page" of the file starts
  219. on a new page of paper.  Emacs treats a page-separator character just
  220. like any other character.  It can be inserted with `C-q C-l', or
  221. deleted with DEL.  You are free to paginate your file or not. 
  222. However, since pages are often meaningful divisions of the file,
  223. commands are provided to move over them and operate on them.
  224.  
  225. `C-x ['
  226.      Move point to previous page boundary (`backward-page').
  227.  
  228. `C-x ]'
  229.      Move point to next page boundary (`forward-page').
  230.  
  231. `C-x C-p'
  232.      Put point and mark around this page (or another page)
  233.      (`mark-page').
  234.  
  235. `C-x l'
  236.      Count the lines in this page (`count-lines-page').
  237.  
  238.    The `C-x [' (`backward-page') command moves point to immediately
  239. after the previous page delimiter.  If point is already right after a
  240. page delimiter, the command skips that one and stops at the previous
  241. one.  A numeric argument serves as a repeat count.  The `C-x ]'
  242. (`forward-page') command moves forward past the next page delimiter.
  243.  
  244.    The `C-x C-p' command (`mark-page') puts point at the beginning of
  245. the current page and the mark at the end.  The page delimiter at the
  246. end is included (the mark follows it).  The page delimiter at the
  247. front is excluded (point follows it).  You can follow this command  by
  248. `C-w' to kill a page you want to move elsewhere.  If you insert the
  249. page after a page delimiter, at a place where `C-x ]' or `C-x [' would
  250. take you, the page will be properly delimited before and after once
  251. again.
  252.  
  253.    A numeric argument to `C-x C-p' is used to specify which page to go
  254. to, relative to the current one.  Zero means the current page.  One
  255. means the next page, and -1 means the previous one.
  256.  
  257.    The `C-x l' command (`count-lines-page') can help you decide where
  258. to break a page in two.  It prints the total number of lines in the
  259. current page in the echo area, then divides the lines into those
  260. preceding the current line and those following it, for example
  261.  
  262.      Page has 96 (72+25) lines
  263.  
  264. Notice that the sum is off by one; this is correct if point is not at
  265. the beginning of a line.
  266.  
  267.    The variable `page-delimiter' should have as its value a regexp that
  268. matches the beginning of a line that separates pages.  This defines
  269. where pages begin.  The normal value of this variable is `"^\f"',
  270. which matches a formfeed character at the beginning of a line.
  271.  
  272. 
  273. File: emacs,  Node: Filling,  Next: Case,  Prev: Pages,  Up: Text
  274.  
  275. Filling Text
  276. ============
  277.  
  278.    If you use Auto Fill mode, Emacs "fills" text (breaks it up into
  279. lines that fit in a specified width) as you insert it.  When you alter
  280. existing text it is often no longer be properly filled afterwards and
  281. you can use explicit commands for filling.
  282.  
  283. * Menu:
  284.  
  285. * Auto Fill::      Auto Fill mode breaks long lines automatically.
  286. * Fill Commands:: Commands to refill paragraphs and center lines.
  287. * Fill Prefix::   Filling when every line is indented or in a comment, etc.
  288.  
  289. 
  290. File: emacs,  Node: Auto Fill,  Next: Fill Commands,  Prev: Filling,  Up: Filling
  291.  
  292. Auto Fill Mode
  293. --------------
  294.  
  295.    "Auto Fill" mode is a minor mode in which lines are broken
  296. automatically when they become too wide.  Breaking happens only when
  297. you type a SPC or RET.
  298.  
  299. `M-x auto-fill-mode'
  300.      Enable or disable Auto Fill mode.
  301.  
  302. `SPC'
  303. `RET'
  304.      In Auto Fill mode, break lines when appropriate.
  305.  
  306.    `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off
  307. if it was on.  With a positive numeric argument the command always
  308. turns Auto Fill mode on, and with a negative argument it always turns
  309. it off.  The presence of the word `Fill' in the mode line, inside the
  310. parentheses, indicates that Auto Fill mode is in effect.  Auto Fill
  311. mode is a minor mode; you can turn it on or off for each buffer
  312. individually.  *Note Minor Modes::.
  313.  
  314.    In Auto Fill mode, lines are broken automatically at spaces when
  315. they get longer than desired.  Line breaking and rearrangement takes
  316. place only when you type SPC or RET.  To insert a space or newline
  317. without permitting line-breaking, type `C-q SPC' or `C-q LFD' (recall
  318. that a newline is really a linefeed).  `C-o' inserts a newline without
  319. line breaking.
  320.  
  321.    Auto Fill mode works well with Lisp mode: when it makes a new line
  322. in Lisp mode it indents that line with TAB.  If a line ending in a
  323. Lisp comment gets too long, the text of the comment is split into two
  324. comment lines.  Optionally new comment delimiters are inserted at the
  325. end of the first line and the beginning of the second, so that each
  326. line is a separate comment.  The variable `comment-multi-line' controls
  327. the choice (*note Comments::.).
  328.  
  329.    Auto Fill mode does not refill entire paragraphs.  It can break
  330. lines but cannot merge lines.  Editing in the middle of a paragraph
  331. can result in a paragraph that is not correctly filled.  The easiest
  332. way to make the paragraph properly filled again is using an explicit
  333. fill commands.
  334.  
  335.    Many users like Auto Fill mode and want to use it in all text files. 
  336. The section on init files explains how you can arrange this
  337. permanently for yourself.  *Note Init File::.
  338.  
  339. 
  340. File: emacs,  Node: Fill Commands,  Next: Fill Prefix,  Prev: Auto Fill,  Up: Filling
  341.  
  342. Explicit Fill Commands
  343. ----------------------
  344.  
  345. `M-q'
  346.      Fill current paragraph (`fill-paragraph').
  347.  
  348. `M-g'
  349.      Fill each paragraph in the region (`fill-region').
  350.  
  351. `C-x f'
  352.      Set the fill column (`set-fill-column').
  353.  
  354. `M-x fill-region-as-paragraph.'
  355.      Fill the region, considering it as one paragraph.
  356.  
  357. `M-s'
  358.      Center a line.
  359.  
  360.    To refill a paragraph, use the command `Meta-q' (`fill-paragraph').
  361.  It causes the paragraph containing point, or the one after point if
  362. point is between paragraphs, to be refilled.  All line breaks are
  363. removed, and new ones are inserted where necessary.  `M-q' can be
  364. undone with `C-_'.  *Note Undo::.
  365.  
  366.    To refill many paragraphs, use `M-g' (`fill-region'), which divides
  367. the region into paragraphs and fills each of them.
  368.  
  369.    `Meta-q' and `Meta-g' use the same criteria as `Meta-h' for finding
  370. paragraph boundaries (*note Paragraphs::.).  For more control, you can
  371. use `M-x fill-region-as-paragraph', which refills everything between
  372. point and mark.  This command recognizes only blank lines as paragraph
  373. separators.
  374.  
  375.    A numeric argument to `M-g' or `M-q' causes it to "justify" the
  376. text as well as filling it.  Extra spaces are inserted to make the
  377. right margin line up exactly at the fill column.  To remove the extra
  378. spaces, use `M-q' or `M-g' with no argument.
  379.  
  380.    The variable `auto-fill-inhibit-regexp'takes as a value a regexp to
  381. match lines that should not be auto-filled.
  382.  
  383.    The command `Meta-s' (`center-line') centers the current line
  384. within the current fill column.  With an argument, it centers several
  385. lines individually and moves past them.
  386.  
  387.    The maximum line width for filling is in the variable
  388. `fill-column'.  Altering the value of `fill-column' makes it local to
  389. the current buffer; until then, the default value--initially 70--is in
  390. effect. *Note Locals::.
  391.  
  392.    The easiest way to set `fill-column' is to use the command `C-x f'
  393. (`set-fill-column').  With no argument, it sets `fill-column' to the
  394. current horizontal position of point.  With a numeric argument, it
  395. uses that number as the new fill column.
  396.  
  397. 
  398. File: emacs,  Node: Fill Prefix,  Prev: Fill Commands,  Up: Filling
  399.  
  400. The Fill Prefix
  401. ---------------
  402.  
  403.    To fill a paragraph in which each line starts with a special marker
  404. (which might be a few spaces, giving an indented paragraph), use the
  405. "fill prefix" feature.  The fill prefix is a string which is not
  406. included in filling.  Emacs expects every line to start with a fill
  407. prefix.
  408.  
  409. `C-x .'
  410.      Set the fill prefix (`set-fill-prefix').
  411.  
  412. `M-q'
  413.      Fill a paragraph using current fill prefix (`fill-paragraph').
  414.  
  415. `M-x fill-individual-paragraphs'
  416.      Fill the region, considering each change of indentation as
  417.      starting a new paragraph.
  418.  
  419.    To specify a fill prefix, move to a line that starts with the
  420. desired prefix, put point at the end of the prefix, and give the
  421. command `C-x .' (`set-fill-prefix').  That's a period after the `C-x'.
  422.  To turn off the fill prefix, specify an empty prefix: type `C-x .'
  423. with point at the beginning of a line.
  424.  
  425.    When a fill prefix is in effect, the fill commands remove the fill
  426. prefix from each line before filling and insert it on each line after
  427. filling.  Auto Fill mode also inserts the fill prefix inserted on new
  428. lines it creates.  Lines that do not start with the fill prefix are
  429. considered to start paragraphs, both in `M-q' and the paragraph
  430. commands; this is just right if you are using paragraphs with hanging
  431. indentation (every line indented except the first one).  Lines which
  432. are blank or indented once the prefix is removed also separate or start
  433. paragraphs; this is what you want if you are writing multi-paragraph
  434. comments with a comment delimiter on each line.
  435.  
  436.    The fill prefix is stored in the variable `fill-prefix'.  Its value
  437. is a string, or `nil' when there is no fill prefix.  This is a
  438. per-buffer variable; altering the variable affects only the current
  439. buffer, but there is a default value which you can change as well. 
  440. *Note Locals::.
  441.  
  442.    Another way to use fill prefixes is through `M-x
  443. fill-individual-paragraphs'.  This function divides the region into
  444. groups of consecutive lines with the same amount and kind of
  445. indentation and fills each group as a paragraph, using its indentation
  446. as a fill prefix.
  447.  
  448. 
  449. File: emacs,  Node: Case,  Prev: Filling,  Up: Text
  450.  
  451. Case Conversion Commands
  452. ========================
  453.  
  454.    Emacs has commands for converting either a single word or any
  455. arbitrary range of text to upper case or to lower case.
  456.  
  457. `M-l'
  458.      Convert following word to lower case (`downcase-word').
  459.  
  460. `M-u'
  461.      Convert following word to upper case (`upcase-word').
  462.  
  463. `M-c'
  464.      Capitalize the following word (`capitalize-word').
  465.  
  466. `C-x C-l'
  467.      Convert region to lower case (`downcase-region').
  468.  
  469. `C-x C-u'
  470.      Convert region to upper case (`upcase-region').
  471.  
  472.    The word conversion commands are used most frequently.  `Meta-l'
  473. (`downcase-word') converts the word after point to lower case, moving
  474. past it.  Thus, repeating `Meta-l' converts successive words. 
  475. `Meta-u' (`upcase-word') converts to all capitals instead, while
  476. `Meta-c' (`capitalize-word') puts the first letter of the word into
  477. upper case and the rest into lower case.  The word conversion commands
  478. convert several words at once if given an argument.  They are
  479. especially convenient for converting a large amount of text from all
  480. upper case to mixed case: you can move through the text using `M-l',
  481. `M-u' or `M-c' on each word as appropriate, occasionally using `M-f'
  482. instead to skip a word.
  483.  
  484.    When given a negative argument, the word case conversion commands
  485. apply to the appropriate number of words before point, but do not move
  486. point.  This is convenient when you have just typed a word in the
  487. wrong case: you can give the case conversion command and continue
  488. typing.
  489.  
  490.    If a word case conversion command is given in the middle of a word,
  491. it applies only to the part of the word which follows point.  This is
  492. just like what `Meta-d' (`kill-word') does.  With a negative argument,
  493. case conversion applies only to the part of the word before point.
  494.  
  495.    The other case conversion commands are `C-x C-u' (`upcase-region')
  496. and `C-x C-l' (`downcase-region'), which convert everything between
  497. point and mark to the specified case.  Point and mark do not move.
  498.  
  499. 
  500. File: emacs,  Node: Programs,  Next: Running,  Prev: Text,  Up: Top
  501.  
  502. Editing Programs
  503. ****************
  504.  
  505.    Emacs has many commands designed to understand the syntax of
  506. programming languages such as Lisp and C.  These commands can
  507.  
  508.    * Move over or kill balanced expressions or "sexps" (*note
  509.      Lists::.).
  510.  
  511.    * Move over or mark top-level balanced expressions ("defuns", in
  512.      Lisp; functions, in C).
  513.  
  514.    * Show how parentheses balance (*note Matching::.).
  515.  
  516.    * Insert, kill or align comments (*note Comments::.).
  517.  
  518.    * Follow the usual indentation conventions of the language (*note
  519.      Grinding::.).
  520.  
  521.    The commands available for words, sentences and paragraphs are
  522. useful in editing code even though their canonical application is for
  523. editing human language text.  Most symbols contain words (*note
  524. Words::.); sentences can be found in strings and comments (*note
  525. Sentences::.).  Paragraphs per se are not present in code, but the
  526. paragraph commands are useful anyway, because Lisp mode and C mode
  527. define paragraphs to begin and end at blank lines (*note
  528. Paragraphs::.).  Judicious use of blank lines to make the program
  529. clearer also provides interesting chunks of text for the paragraph
  530. commands to work on.
  531.  
  532.    The selective display feature is useful for looking at the overall
  533. structure of a function (*note Selective Display::.).  This feature
  534. causes only the lines that are indented less than a specified amount
  535. to appear on the screen.
  536.  
  537. * Menu:
  538.  
  539. * Program Modes::       Major modes for editing programs.
  540. * Lists::               Expressions with balanced parentheses.
  541.                          There are editing commands to operate on them.
  542. * Defuns::              Each program is made up of separate functions.
  543.                          There are editing commands to operate on them.
  544. * Grinding::            Adjusting indentation to show the nesting.
  545. * Matching::            Insertion of a close-delimiter flashes matching open.
  546. * Comments::            Inserting, illing and aligning comments.
  547. * Balanced Editing::    Inserting two matching parentheses at once, etc.
  548. * Lisp Completion::     Completion on symbol names in Lisp code.
  549. * Documentation::       Getting documentation of functions you plan to call.
  550. * Change Log::          Maintaining a change history for your program.
  551. * Tags::                Go direct to any function in your program in one
  552.                          command.  Tags remembers which file it is in.
  553. * Fortran::        Fortran mode and its special features.
  554.  
  555. 
  556. File: emacs,  Node: Program Modes,  Next: Lists,  Prev: Programs,  Up: Programs
  557.  
  558. Major Modes for Programming Languages
  559. =====================================
  560.  
  561.    Emacs has several major modes for the programming languages Lisp,
  562. Scheme (a variant of Lisp), C, Fortran and Muddle.  Ideally, a major
  563. mode should be implemented for each programming language you might
  564. want to edit with Emacs; but often the mode for one language can serve
  565. for other syntactically similar languages.  The language modes that
  566. exist are those that someone decided to take the trouble to write.
  567.  
  568.    There are several variants of Lisp mode, which differ in the way
  569. they interface to Lisp execution.  *Note Lisp Modes::.
  570.  
  571.    Each of the programming language modes defines the TAB key to run
  572. an indentation function that knows the indentation conventions of that
  573. language and updates the current line's indentation accordingly.  For
  574. example, in C mode TAB is bound to `c-indent-line'.  LFD is normally
  575. defined to do RET followed by TAB; thus, it too indents in a
  576. mode-specific fashion.
  577.  
  578.    In most programming languages, indentation is likely to vary from
  579. line to line.  So the major modes for those languages rebind DEL to
  580. treat a tab as if it were the equivalent number of spaces (using the
  581. command `backward-delete-char-untabify').  This makes it possible to
  582. rub out indentation one column at a time without worrying whether it
  583. is made up of spaces or tabs.  In these modes, use `C-b C-d' to delete
  584. a tab character before point.
  585.  
  586.    Programming language modes define paragraphs to be separated only by
  587. blank lines, so that the paragraph commands remain useful.  Auto Fill
  588. mode, if enabled in a programming language major mode, indents the new
  589. lines which it creates.
  590.  
  591.    Turning on a major mode calls a user-supplied function called the
  592. "mode hook", which is the value of a Lisp variable.  For example,
  593. turning on C mode calls the value of the variable `c-mode-hook' if
  594. that value exists and is non-`nil'.  Mode hook variables for other
  595. programming language modes include `lisp-mode-hook',
  596. `emacs-lisp-mode-hook', `lisp-interaction-mode-hook',
  597. `scheme-mode-hook' and `muddle-mode-hook'.  The mode hook function
  598. receives no arguments.
  599.  
  600. 
  601. File: emacs,  Node: Lists,  Next: Defuns,  Prev: Program Modes,  Up: Programs
  602.  
  603. Lists and Sexps
  604. ===============
  605.  
  606.    By convention, Emacs keys for dealing with balanced expressions are
  607. usually `Control-Meta-' characters.  They tend to be analogous in
  608. function to their `Control-' and `Meta-' equivalents.  These commands
  609. are usually thought of as pertaining to expressions in programming
  610. languages, but can be useful with any language in which some sort of
  611. parentheses exist (including English).
  612.  
  613.    The commands fall into two classes.  Some commands deal only with
  614. "lists" (parenthetical groupings).  They see nothing except
  615. parentheses, brackets, braces (depending on what must balance in the
  616. language you are working with), and escape characters that might be
  617. used to quote those.
  618.  
  619.    The other commands deal with expressions or "sexps".  The word
  620. `sexp' is derived from "s-expression", the term for an expression in
  621. Lisp.  In Emacs, the notion of `sexp' is not limited to Lisp.  It
  622. refers to an expression in the language  your program is written in. 
  623. Each programming language has its own major mode, which customizes the
  624. syntax tables so that expressions in that language count as sexps.
  625.  
  626.    Sexps typically include symbols, numbers, and string constants, as
  627. well as anything contained in parentheses, brackets or braces.
  628.  
  629.    In languages that use prefix and infix operators, such as C, it is
  630. not possible for all expressions to be sexps.  For example, C mode
  631. does not recognize `foo + bar' as an sexp, even though it is a C
  632. expression; it recognizes `foo' as one sexp and `bar' as another, with
  633. the `+' as punctuation between them.  This is a fundamental ambiguity:
  634. both `foo + bar' and `foo' are legitimate choices for the sexp to move
  635. over if point is at the `f'.  Note that `(foo + bar)' is a sexp in C
  636. mode.
  637.  
  638.    Some languages have obscure forms of syntax for expressions that
  639. nobody has bothered to make Emacs understand properly.
  640.  
  641. `C-M-f'
  642.      Move forward over an sexp (`forward-sexp').
  643.  
  644. `C-M-b'
  645.      Move backward over an sexp (`backward-sexp').
  646.  
  647. `C-M-k'
  648.      Kill sexp forward (`kill-sexp').
  649.  
  650. `C-M-u'
  651.      Move up and backward in list structure (`backward-up-list').
  652.  
  653. `C-M-d'
  654.      Move down and forward in list structure (`down-list').
  655.  
  656. `C-M-n'
  657.      Move forward over a list (`forward-list').
  658.  
  659. `C-M-p'
  660.      Move backward over a list (`backward-list').
  661.  
  662. `C-M-t'
  663.      Transpose expressions (`transpose-sexps').
  664.  
  665. `C-M-@'
  666.      Put mark after following expression (`mark-sexp').
  667.  
  668.    To move forward over an sexp, use `C-M-f' (`forward-sexp').  If the
  669. first significant character after point is an opening delimiter (`('
  670. in Lisp; `(', `[' or `{' in C), `C-M-f' moves past the matching
  671. closing delimiter.  If the character begins a symbol, string, or
  672. number, `C-M-f' moves over that.  If the character after point is a
  673. closing delimiter, `C-M-f' just moves past it.  (This last is not
  674. really moving across an sexp; it is an exception which is included in
  675. the definition of `C-M-f' because it is as useful a behavior as anyone
  676. can think of for that situation.)
  677.  
  678.    The command `C-M-b' (`backward-sexp') moves backward over a sexp. 
  679. The detailed rules are like those above for `C-M-f', but with
  680. directions reversed.  If there are any prefix characters (singlequote,
  681. backquote and comma, in Lisp) preceding the sexp, `C-M-b' moves back
  682. over them as well.
  683.  
  684.    `C-M-f' or `C-M-b' with an argument repeats that operation the
  685. specified number of times; with a negative argument, it moves in the
  686. opposite direction.
  687.  
  688.    In languages such as C where the comment-terminator can be
  689. recognized, the sexp commands move across comments as if they were
  690. whitespace.  In Lisp, and other languages where comments run until the
  691. end of a line, it is very difficult to ignore comments when parsing
  692. backwards; therefore, in such languages the sexp commands treat the
  693. text of comments as if it were code.
  694.  
  695.    Killing an sexp at a time can be done with `C-M-k' (`kill-sexp'). 
  696. `C-M-k' kills the characters that `C-M-f' would move over.
  697.  
  698.    The "list commands", `C-M-n' (`forward-list') and `C-M-p'
  699. (`backward-list'), move over lists like the sexp commands but skip
  700. over any number of other kinds of sexps (symbols, strings, etc).  In
  701. some situations, these commands are useful because they usually ignore
  702. comments, since the comments usually do not contain any lists.
  703.  
  704.    `C-M-n' and `C-M-p' stay at the same level in parentheses, when
  705. that is possible.  To move up one (or N) levels, use `C-M-u'
  706. (`backward-up-list').  `C-M-u' moves backward up past one unmatched
  707. opening delimiter.  A positive argument serves as a repeat count; a
  708. negative argument reverses direction of motion and also requests
  709. repetition, so it moves forward and up one or more levels.
  710.  
  711.    To move down in list structure, use `C-M-d' (`down-list').  In Lisp
  712. mode, where `(' is the only opening delimiter, this is nearly the same
  713. as searching for a `('.  An argument specifies the number of levels of
  714. parentheses to go down.
  715.  
  716.    `C-M-t' (`transpose-sexps') drags the previous sexp across the next
  717. one.  An argument serves as a repeat count, and a negative argument
  718. drags backwards (thus canceling out the effect of `C-M-t' with a
  719. positive argument).  An argument of zero, rather than doing nothing,
  720. transposes the sexps ending after point and the mark.
  721.  
  722.    To make the region be the next sexp in the buffer, use `C-M-@'
  723. (`mark-sexp') which sets the mark at the same place that `C-M-f' would
  724. move to.  `C-M-@' takes arguments like `C-M-f'.  In particular, a
  725. negative argument is useful for putting the mark at the beginning of
  726. the previous sexp.
  727.  
  728.    The list and sexp commands' understanding of syntax is completely
  729. controlled by the syntax table.  Any character can, for example, be
  730. declared to be an opening delimiter and act like an open parenthesis. 
  731. *Note Syntax::.
  732.  
  733. 
  734. File: emacs,  Node: Defuns,  Next: Grinding,  Prev: Lists,  Up: Programs
  735.  
  736. Defuns
  737. ======
  738.  
  739.    In Emacs, a parenthetical grouping at the top level in the buffer is
  740. called a "defun".  The name derives from the fact that most top-level
  741. lists in a Lisp file are instances of the special form `defun', but in
  742. Emacs terminology, any top-level parenthetical grouping counts as a
  743. defun regardless of its contents, and regardless of the programming
  744. language in use.  For example, in C, the body of a function definition
  745. is a defun.
  746.  
  747. `C-M-a'
  748.      Move to beginning of current or preceding defun
  749.      (`beginning-of-defun').
  750.  
  751. `C-M-e'
  752.      Move to end of current or following defun (`end-of-defun').
  753.  
  754. `C-M-h'
  755.      Put region around whole current or following defun (`mark-defun').
  756.  
  757.    The commands to move to the beginning and end of the current defun
  758. are `C-M-a' (`beginning-of-defun') and `C-M-e' (`end-of-defun').
  759.  
  760.    To operate on the current defun, use `C-M-h' (`mark-defun') which
  761. puts point at the beginning and the mark at the end of the current or
  762. next defun.  This is the easiest way to prepare for moving the defun
  763. to a different place.  In C mode, `C-M-h' runs the function
  764. `mark-c-function', which is almost the same as `mark-defun', but which
  765. backs up over the argument declarations, function name, and returned
  766. data type so that the entire C function is inside th e region.
  767.  
  768.    To compile and evaluate the current defun, use `M-x
  769. elisp-compile-defun'. This function prints the results in the
  770. minibuffer. If you include an argument, it inserts the value in the
  771. current buffer after the defun.
  772.  
  773.    Emacs assumes that any open-parenthesis found in the leftmost
  774. column is the start of a defun.  Therefore, never put an
  775. open-parenthesis at the left margin in a Lisp file unless it is the
  776. start of a top level list.  Never put an open-brace or other opening
  777. delimiter at the beginning of a line of C code unless it starts the
  778. body of a function.  The most likely problem case is when you want an
  779. opening delimiter at the start of a line inside a string.  To avoid
  780. trouble, put an escape character (`\', in C and Emacs Lisp, `/' in
  781. some other Lisp dialects) before the opening delimiter.  It will not
  782. affect the contents of the string.
  783.  
  784.    The original Emacs found defuns by moving upward a level of
  785. parentheses until there were no more levels to go up.  This always
  786. required scanning back to the beginning of the buffer, even for a
  787. small function.  To speed up the operation, Emacs was changed to assume
  788. that any `(' (or other character assigned the syntactic class of
  789. opening-delimiter) at the left margin is the start of a defun.  This
  790. heuristic is nearly always right and avoids the costly scan; however,
  791. it mandates the convention described above.
  792.  
  793. 
  794. File: emacs,  Node: Grinding,  Next: Matching,  Prev: Defuns,  Up: Programs
  795.  
  796. Indentation for Programs
  797. ========================
  798.  
  799.    The best way to keep a program properly indented ("ground") is to
  800. use Emacs to re-indent it as you change the program.  Emacs has
  801. commands to indent properly either a single line, a specified number
  802. of lines, or all of the lines inside a single parenthetical grouping.
  803.  
  804. * Menu:
  805.  
  806. * Basic Indent::
  807. * Multi-line Indent::   Commands to reindent many lines at once.
  808. * Lisp Indent::        Specifying how each Lisp function should be indented.
  809. * C Indent::        Choosing an indentation style for C code.
  810.  
  811. 
  812. File: emacs,  Node: Basic Indent,  Next: Multi-line Indent,  Prev: Grinding,  Up: Grinding
  813.  
  814. Basic Program Indentation Commands
  815. ----------------------------------
  816.  
  817. `TAB'
  818.      Adjust indentation of current line.
  819.  
  820. `LFD'
  821.      Equivalent to RET followed by TAB (`newline-and-indent').
  822.  
  823.    The basic indentation command is TAB, which gives the current line
  824. the correct indentation as determined from the previous lines.  The
  825. function that TAB runs depends on the major mode; it is
  826. `lisp-indent-line' in Lisp mode, `c-indent-line' in C mode, etc. 
  827. These functions understand different syntaxes for different languages,
  828. but they all do about the same thing.  TAB in any programming language
  829. major mode inserts or deletes whitespace at the beginning of the
  830. current line, independent of where point is in the line.  If point is
  831. inside the whitespace at the beginning of the line, TAB leaves it at
  832. the end of that whitespace; otherwise, TAB leaves point fixed with
  833. respect to the characters around it.
  834.  
  835.    Use `C-q TAB' to insert a tab at point.
  836.  
  837.    When entering a large amount of new code, use LFD
  838. (`newline-and-indent'), which is equivalent to a RET followed by a
  839. TAB.  LFD creates a blank line, then gives it the appropriate
  840. indentation.
  841.  
  842.    TAB indents the second and following lines of the body of a
  843. parenthetical grouping each under the preceding one; therefore, if you
  844. alter one line's indentation to be nonstandard, the lines below tend
  845. to follow it.  This is the right behavior in cases where the standard
  846. result of TAB does not look good.
  847.  
  848.    Remember that Emacs assumes that an open-parenthesis, open-brace or
  849. other opening delimiter at the left margin (including the indentation
  850. routines) is the start of a function.  You should therefore never have
  851. an opening delimiter in column zero that is not the beginning of a
  852. function, not even inside a string.  This restriction is vital for
  853. making the indentation commands fast. *Note Defuns::, for more
  854. information on this behavior.
  855.  
  856. 
  857. File: emacs,  Node: Multi-line Indent,  Next: Lisp Indent,  Prev: Basic Indent,  Up: Grinding
  858.  
  859. Indenting Several Lines
  860. -----------------------
  861.  
  862.    Several commands are available to re-indent several lines of code
  863. which have been altered or moved to a different level in a list
  864. structure,
  865.  
  866. `C-M-q'
  867.      Re-indent all the lines within one list (`indent-sexp').
  868.  
  869. `C-u TAB'
  870.      Shift an entire list rigidly sideways so that its first line is
  871.      properly indented.
  872.  
  873. `C-M-\'
  874.      Re-indent all lines in the region (`indent-region').
  875.  
  876.    To re-indent the contents of a single list, position point before
  877. the beginning of it and type `C-M-q'. This key is bound to
  878. `indent-sexp' in Lisp mode, `indent-c-exp' in C mode, and bound to
  879. other suitable functions in other modes.  The indentation of the line
  880. the sexp starts on is not changed; therefore, only the relative
  881. indentation within the list, and not its position, is changed.  To
  882. correct the position as well, type a TAB before `C-M-q'.
  883.  
  884.    If the relative indentation within a list is correct but the
  885. indentation of its beginning is not, go to the line on which the list
  886. begins and type `C-u TAB'.  When you give TAB a numeric argument, it
  887. moves all the lines in the group, starting on the current line,
  888. sideways the same amount that the current line moves.  The command
  889. does not move lines that start inside strings, or C preprocessor lines
  890. when in C mode.
  891.  
  892.    Another way to specify a range to be re-indented is with point and
  893. mark.  The command `C-M-\' (`indent-region') applies TAB to every line
  894. whose first character is between point and mark.
  895.  
  896. 
  897. File: emacs,  Node: Lisp Indent,  Next: C Indent,  Prev: Multi-line Indent,  Up: Grinding
  898.  
  899. Customizing Lisp Indentation
  900. ----------------------------
  901.  
  902.    The indentation pattern for a Lisp expression can depend on the
  903. function called by the expression.  For each Lisp function, you can
  904. choose among several predefined patterns of indentation, or define an
  905. arbitrary one with a Lisp program.
  906.  
  907.    The standard pattern of indentation is as follows: the second line
  908. of the expression is indented under the first argument, if that is on
  909. the same line as the beginning of the expression; otherwise, the
  910. second line is indented underneath the function name.  Each following
  911. line is indented under the previous line whose nesting depth is the
  912. same.
  913.  
  914.    If the variable `lisp-indent-offset' is non-`nil', it overrides the
  915. usual indentation pattern for the second line of an expression, so that
  916. such lines are always indented `lisp-indent-offset' more columns than
  917. the containing list.
  918.  
  919.    Certain functions override the standard pattern.  Functions whose
  920. names start with `def' always indent the second line by
  921. `lisp-body-indention' extra columns beyond the open-parenthesis
  922. starting the expression.
  923.  
  924.    Individual functions can override the standard pattern in various
  925. ways, according to the `lisp-indent-function' property of the function
  926. name.  (Note: `lisp-indent-function' was formerly called
  927. `lisp-indent-hook').  There are four possibilities for this property:
  928.  
  929. `nil'
  930.      This is the same as no property; the standard indentation pattern
  931.      is used.
  932.  
  933. `defun'
  934.      The pattern used for function names that start with `def' is used
  935.      for this function also.
  936.  
  937. a number, NUMBER
  938.      The first NUMBER arguments of the function are "distinguished"
  939.      arguments; the rest are considered the "body" of the expression. 
  940.      A line in the expression is indented according to whether the
  941.      first argument on it is distinguished or not.  If the argument is
  942.      part of the body, the line is indented `lisp-body-indent' more
  943.      columns than the open-parenthesis starting the containing
  944.      expression.  If the argument is distinguished and is either the
  945.      first or second argument, it is indented twice that many extra
  946.      columns.  If the argument is distinguished and not the first or
  947.      second argument, the standard pattern is followed for that line.
  948.  
  949. a symbol, SYMBOL
  950.      SYMBOL should be a function name; that function is called to
  951.      calculate the indentation of a line within this expression.  The
  952.      function receives two arguments:
  953.  
  954.     STATE
  955.           The value returned by `parse-partial-sexp' (a Lisp primitive
  956.           for indentation and nesting computation) when it parses up
  957.           to the beginning of this line.
  958.  
  959.     POS
  960.           The position at which the line being indented begins.
  961.  
  962.           It should return either a number, which is the number of columns
  963.      of indentation for that line, or a list whose first element is
  964.      such a number.  The difference between returning a number and
  965.      returning a list is that a number says that all following lines
  966.      at the same nesting level should be indented just like this one;
  967.      a list says that following lines might call for different
  968.      indentations.  This makes a difference when the indentation is
  969.      computed by `C-M-q'; if the value is a number, `C-M-q' need not
  970.      recalculate indentation for the following lines until the end of
  971.      the list.
  972.  
  973. 
  974. File: emacs,  Node: C Indent,  Prev: Lisp Indent,  Up: Grinding
  975.  
  976. Customizing C Indentation
  977. -------------------------
  978.  
  979.    Two variables control which commands perform C indentation and when.
  980.  
  981.    If `c-auto-newline' is non-`nil', newlines are inserted both before
  982. and after braces that you insert, and after colons and semicolons. 
  983. Correct C indentation is done on all the lines that are made this way.
  984.  
  985.    If `c-tab-always-indent' is non-`nil', the TAB command in C mode
  986. does indentation only if point is at the left margin or within the
  987. line's indentation.  If there is non-whitespace to the left of point,
  988. TAB just inserts a tab character in the buffer.  Normally, this
  989. variable is `nil', and TAB always reindents the current line.
  990.  
  991.    C does not have anything analogous to particular function names for
  992. which special forms of indentation are desirable.  However, it has a
  993. different need for customization facilities: many different styles of
  994. C indentation are in common use.
  995.  
  996.    There are six variables you can set to control the style that Emacs
  997. C mode will use.
  998.  
  999. `c-indent-level'
  1000.      Indentation of C statements within surrounding block.  The
  1001.      surrounding block's indentation is the indentation of the line on
  1002.      which the open-brace appears.
  1003.  
  1004. `c-continued-statement-offset'
  1005.      Extra indentation given to a substatement, such as the
  1006.      then-clause of an if or body of a while.
  1007.  
  1008. `c-brace-offset'
  1009.      Extra indentation for lines that start with an open brace.
  1010.  
  1011. `c-brace-imaginary-offset'
  1012.      An open brace following other text is treated as if it were this
  1013.      far to the right of the start of its line.
  1014.  
  1015. `c-argdecl-indent'
  1016.      Indentation level of declarations of C function arguments.
  1017.  
  1018. `c-label-offset'
  1019.      Extra indentation for a line that is a label, case, or default.
  1020.  
  1021.    The variable `c-indent-level' controls the indentation for C
  1022. statements with respect to the surrounding block.  In the example
  1023.  
  1024.          {
  1025.            foo ();
  1026.  
  1027. the difference in indentation between the lines is `c-indent-level'. 
  1028. Its standard value is 2.
  1029.  
  1030.    If the open-brace beginning the compound statement is not at the
  1031. beginning of its line, the `c-indent-level' is added to the
  1032. indentation of the line, not the column of the open-brace.  For
  1033. example,
  1034.  
  1035.      if (losing) {
  1036.        do_this ();
  1037.  
  1038. One popular indentation style is that which results from setting
  1039. `c-indent-level' to 8 and putting open-braces at the end of a line in
  1040. this way.  Another popular style prefers to put the open-brace on a
  1041. separate line.
  1042.  
  1043.    In fact, the value of the variable `c-brace-imaginary-offset' is
  1044. also added to the indentation of such a statement.  Normally this
  1045. variable is zero.  Think of this variable as the imaginary position of
  1046. the open brace, relative to the first non-blank character on the line.
  1047.  By setting the variable to 4 and `c-indent-level' to 0, you can get
  1048. this style:
  1049.  
  1050.      if (x == y) {
  1051.          do_it ();
  1052.          }
  1053.  
  1054.    When `c-indent-level' is zero, the statements inside most braces
  1055. line up exactly under the open brace.  An exception are braces in
  1056. column zero, like those surrounding a function's body.  The statements
  1057. inside those braces are not placed at column zero.  Instead,
  1058. `c-brace-offset' and `c-continued-statement-offset' (see below) are
  1059. added to produce a typical offset between brace levels, and the
  1060. statements are indented that far.
  1061.  
  1062.    `c-continued-statement-offset' controls the extra indentation for a
  1063. line that starts within a statement (but not within parentheses or
  1064. brackets).  These lines are usually statements inside other statements,
  1065. like the then-clauses of `if' statements and the bodies of `while'
  1066. statements.  The `c-continued-statement-offset' parameter determines
  1067. the difference in indentation between the two lines in
  1068.  
  1069.      if (x == y)
  1070.        do_it ();
  1071.  
  1072. The default value for `c-continued-statement-offset' is 2.  Some
  1073. popular indentation styles correspond to a value of zero for
  1074. `c-continued-statement-offset'.
  1075.  
  1076.    `c-brace-offset' is the extra indentation given to a line that
  1077. starts with an open-brace.  Its standard value is zero; compare
  1078.  
  1079.      if (x == y)
  1080.        {
  1081.  
  1082. with
  1083.  
  1084.      if (x == y)
  1085.        do_it ();
  1086.  
  1087. if you set `c-brace-offset' to 4, the first example becomes
  1088.  
  1089.      if (x == y)
  1090.            {
  1091.  
  1092.    `c-argdecl-indent' controls the indentation of declarations of the
  1093. arguments of a C function.  It is absolute: argument declarations
  1094. receive exactly `c-argdecl-indent' spaces.  The standard value is 5 and
  1095. results in code like this:
  1096.  
  1097.      char *
  1098.      index (string, char)
  1099.           char *string;
  1100.           int char;
  1101.  
  1102.    `c-label-offset' is the extra indentation given to a line that
  1103. contains a label, a case statement, or a `default:' statement.  Its
  1104. standard value is -2 and results in code like this
  1105.  
  1106.      switch (c)
  1107.        {
  1108.        case 'x':
  1109.  
  1110. If `c-label-offset' were zero, the same code would be indented as
  1111.  
  1112.      switch (c)
  1113.        {
  1114.          case 'x':
  1115.  
  1116. This example assumes that the other variables above also have their
  1117. default values.
  1118.  
  1119.    Using the indentation style produced by the default settings of the
  1120. variables just discussed, and putting open braces on separate lines
  1121. produces clear and readable files.  For an example, look at any of the
  1122. C source files of GNU Emacs.
  1123.  
  1124. 
  1125. File: emacs,  Node: Matching,  Next: Comments,  Prev: Grinding,  Up: Programs
  1126.  
  1127. Automatic Display of Matching Parentheses
  1128. =========================================
  1129.  
  1130.    The Emacs parenthesis-matching feature shows you automatically how
  1131. parentheses match in the text.  Whenever a self-inserting character
  1132. that is a closing delimiter is typed, the cursor moves momentarily to
  1133. the location of the matching opening delimiter, provided that is
  1134. visible on the screen.  If it is not on the screen, some text starting
  1135. with that opening delimiter is displayed in the echo area.  Either
  1136. way, you see the grouping you are closing off.
  1137.  
  1138.    In Lisp, automatic matching applies only to parentheses.  In C, it
  1139. also applies to braces and brackets.  Emacs knows which characters to
  1140. regard as matching delimiters based on the syntax table set by the
  1141. major mode.  *Note Syntax::.
  1142.  
  1143.    If the opening delimiter and closing delimiter are mismatched--such
  1144. as in `[x)'--the echo area displays a warning message.  The correct
  1145. matches are specified in the syntax table.
  1146.  
  1147.    Two variables control parenthesis matching displays. 
  1148. `blink-matching-paren' turns the feature on or off: `nil' turns it
  1149. off, but the default is `t' to turn match display on. 
  1150. `blink-matching-paren-distance' specifies how many characters back
  1151. Emacs searches to find a matching opening delimiter.  If the match is
  1152. not found in the specified region, scanning stops, and nothing is
  1153. displayed.  This prevents wasting lots of time scanning when there is
  1154. no match.  The default is 4000.
  1155.  
  1156.